import {INCREMENT} from 'Stores/EVENTS'
import count from 'Stores/states/count.yaml'

/*
	数据的占位符，这里面存放的都是默认值
*/
const state = count;
/*
	set方法，要求都是同步方法，不能做异步处理
	store.commit(INCREMENT, 额外参数)
*/
const mutations = {
	[INCREMENT](state){
		state.count++;
	}
}
/*
	get方法
*/
const getters = {
	largeOne : state => state.count>0?"杨过":"郭静",
}
/*
	异步获取数据的方法
	store.dispatch('incrementAsync', {
	  amount: 10
	})
*/
const actions={
	[INCREMENT]: function ({commit}) {
		setTimeout(function () {
			commit(INCREMENT);
		},1000)
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	getters,
	actions
}